package com.hxd.mall.module.school.article

import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hxd.mall.R
import com.hxd.mall.constant.HxdGlobalInfo.instance
import com.hxd.mall.module.school.bean.ItemResource
import com.hxd.mall.utils.open.load
import com.hxd.mall.utils.open.loadRectangularImg
import com.hxd.mall.utils.open.loadRectangularImg2
import org.jetbrains.anko.dip
import org.jetbrains.anko.displayMetrics


/**
 * @author zhaoyong
 * @description:
 * @date :2019-10-14 18:54
 */
class ArticleAllListAdapter(var mWidth:Int? = (instance.displayMetrics.widthPixels- instance.dip(40))/2, var mHeight :Int?=mWidth!!*3/4 ) :
    BaseQuickAdapter<ItemResource, BaseViewHolder>(R.layout.adapter_all_article_list_item_layout) {
    override fun convert(helper: BaseViewHolder?, item: ItemResource?) {
        helper?.run {
            getView<ImageView>(R.id.iv_pic).run {
                loadRectangularImg2(item?.pictUri, R.mipmap.product_item_icon, R.mipmap.product_item_icon,iv =this,ivWidth = mWidth ,ivHeight = mHeight )
            }
            getView<TextView>(R.id.title).text = item?.title ?: ""
        }
    }
}